package cn.bocweb.spinning.model.Imp;

import cn.bocweb.spinning.model.Bean.ErrorBean;
import cn.bocweb.spinning.util.Constant;
import cn.bocweb.spinning.util.DeviceUtil;
import de.greenrobot.event.EventBus;
import retrofit.Callback;
import retrofit.Response;
import retrofit.Retrofit;


/**
 * Created by chenchangxing on 16/1/7.
 */
public class MyCallback<T> implements Callback<T> {

    @Override
    public void onResponse(Response<T> response, Retrofit retrofit) {
        EventBus.getDefault().post(response.body());
    }

    @Override
    public void onFailure(Throwable t) {
        DeviceUtil.Log(t.toString());
        ErrorBean errorBean = new ErrorBean();
        errorBean.setErrorMsg(Constant.NETWORK_ERROR);
        EventBus.getDefault().post(errorBean);
    }
}
